import requests
from threading import Thread
# from multiprocessing import process

# request请求lol官网
def request_lol(index):
    url = "https://lol.qq.com/act/a20210108lplspring/index.shtml?e_code=507042"
    # body = ""
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
    }
    response = requests.get(url=url, headers=headers)
    print(f"当前请求序号： {index}, 返回结果状态码: {response.status_code}")


if __name__ == "__main__":
# 实现一个多线程
    thread_array = []
    for i in range(10):
        t = Thread(target=request_lol, args=(i, ))
        thread_array.append(t)
        t.start()
    for t in thread_array:
        t.join()
    print("done!")

# 将多线程改为多进程
#   process_array = []
#   for i in range(10):
#       p = process(target=request_lol())
#       process_array.append(p)
#       p.start()
#   for p in process_array:
#       p.join()
